﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data;

using QLTTAN.DTO;
namespace QLTTAN.DAL
{
    public class PhongHocDAL
    {
        ConnectionData conn;

        public DataTable PhongHoc_Load()
        {
            conn = new ConnectionData();
            return conn.GetData("PHONGHOC_LOAD");
        }

        public int PhongHoc_Insert(PhongHocDTO PH_DTO)
        {
            conn = new ConnectionData();

            int Nparameter = 2;
            string[] name = new string[Nparameter];
            object[] value = new object[Nparameter];

            name[0] = "TenPhong";
            value[0] = PH_DTO.TenPhong;
            name[1] = "GhiChu";
            value[1] = PH_DTO.GhiChu;

            return conn.UpdateData("PHONGHOC_INSERT", name, value, Nparameter);
        }

        public int PhongHoc_Update(PhongHocDTO PH_DTO)
        {
            conn = new ConnectionData();

            int Nparameter = 3;
            string[] name = new string[Nparameter];
            object[] value = new object[Nparameter];

            name[0] = "MaPhong";
            value[0] = PH_DTO.MaPhong;
            name[1] = "TenPhong";
            value[1] = PH_DTO.TenPhong;
            name[2] = "GhiChu";
            value[2] = PH_DTO.GhiChu;

            return conn.UpdateData("PHONGHOC_UPDATE", name, value, Nparameter);
        }

        public int PhongHoc_Delete(PhongHocDTO PH_DTO)
        {
            conn = new ConnectionData();

            int Nparameter = 1;
            string[] name = new string[Nparameter];
            object[] value = new object[Nparameter];

            name[0] = "MaPhong";
            value[0] = PH_DTO.MaPhong;

            return conn.UpdateData("PHONGHOC_DELETE", name, value, Nparameter);
        }
    }
}
